package com.cty;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test06 {
    public static void main(String[] args) {
        String URL="http://www.nihao.com:8080/abc/index.html";
        //要求解析 协议 域名 端口 文件名
        String regStr="^([a-zA-Z]+)://(([\\w]+\\.)+[\\w]+):([\\w]+)(([/*-+.!@#$%^&*]+[\\w]+)*)";
        Pattern compile = Pattern.compile(regStr);
        Matcher matcher = compile.matcher(URL);
        while (matcher.find()) {
            System.out.println("协议："+matcher.group(1)+","+"域名："+matcher.group(2)+","+"端口："
                    +matcher.group(4)+","+"文件名"+matcher.group(5));
        }
    }
}
